<?php

		if(isset($_POST['ajax_pagination'])){
					$cache=new Cache;
					$url=$_POST['url']."&page=";
					$_GET['page']=$_POST['page'];
		$sql ="select id from truyen  where duyet=1 order by time_update desc ";
		$sql2="select id from truyen where duyet=1 ";
		$pager = new Pagination2($sql,15,4,$url,0,"truyen_1");
		$pager->ajax=1;
		$pager->setDebug(false);
		$data['truyenmoi']['data'] = $pager->paginate($cache,$sql2);
		$data['truyenmoi']['nav']=$pager->renderFullNav();
		//Render data---?>
		 <div class='text-center'><?php echo $data['truyenmoi']['nav']; ?></div>
         	<?php
			echo truyen_render_list_item($data['truyenmoi']['data']);
			?>
         <div class='text-center'><?php echo $data['truyenmoi']['nav']; ?></div> 
         <?php
		exit();
		}
		$cache=new Cache;
		$data=$cache->load('home_data11','truyen',1);
		if(!$data){
				//TRUYEN PICK
				$sql ="select id from truyen  where pick = 1 and duyet=1 order by time_update desc ";
				$sql2="select id from truyen where pick = 1 ";
			
				$pager = new Pagination2($sql,6,4,'',0,"truyen_1");
				$pager->setDebug(false);
				$data['decu'] = $pager->paginate($cache,$sql2);
				$total= $pager->total_rows;

				$data['decu_pages'] = ceil($total / DECU_ITEMS);
				if($data['decu_pages'] > DECU_MAX_PAGE){
					$data['decu_pages'] = DECU_MAX_PAGE;
				}
		
		
				//TRUYEN MOI
				$sql ="select id from truyen  where  duyet=1 order by id desc ";
				$sql2="select id from truyen where pick = 1 ";
			
				$pager = new Pagination2($sql,6,4,'',0,"truyen_1");
				$pager->setDebug(false);
				$data['moi'] = $pager->paginate($cache,$sql2);
				$total= $pager->total_rows;

				$data['moi_pages'] = ceil($total / DECU_ITEMS);
				if($data['moi_pages'] > DECU_MAX_PAGE){
					$data['moi_pages'] = DECU_MAX_PAGE;
				}
		
	
		
		$sql ="select id from truyen  where duyet=1 order by time_update desc ";
		$sql2="select id from truyen where duyet=1 ";
		$pager = new Pagination2($sql,15,4,url()."&page=",0,"truyen_1");
		$pager->ajax=1;
		$pager->setDebug(false);
		$data['truyenmoi']['data'] = $pager->paginate($cache,$sql2);
		$data['truyenmoi']['nav']=$pager->renderFullNav();
		
		
		$cache->save('home_data',$data,300,'truyen',1);
		}
	
			
		
		$og='
<meta property="og:type" content="website" />
<meta property="og:image" content="http://mong.vn/public/images/logo2.png" />
<meta property="og:locale" content="vi_VN" /> 
<meta property="og:title" content="Đọc Truyện Online, Xem Video , Blog | Mong.vn - Kết nối trái tim" />
<meta property="og:description" content=" Đọc và chia sẻ các thể loại truyện chữ Online, xem video clip, blog miễn phí - Mộng.vn"/> 
<meta property="og:url" content="http://mong.vn"/> ';
   $data1['og']=$og;
   $data1['title']=HEAD;
   $data1['keyword']=KEYWORD;
   $data1['mota']=DES;
			
			
			
			loadview('template/header_truyen',$data1);
			loadview("truyen/home",$data);
			loadview('template/footer_truyen',$data1);
			exit();
			
